package com.kevin.strategy;

import com.kevin.factory.CashNormal;
import com.kevin.factory.CashRebate;
import com.kevin.factory.CashReturn;
import com.kevin.factory.CashSuper;

/**
 * 策略类
 *
 * @author kevin
 * @date 2025/8/5
 */
public class CashContext {

    private final CashSuper cashSuper;

   public CashContext(String type){
       this.cashSuper = switch (type){
           case "满300返100" -> new CashReturn(300, 100);
           case "打8折" -> new CashRebate(0.8);
           default -> new CashNormal();
       };
   }

    public double getResult(double money){
        return cashSuper.acceptCash(money);
    }
}
